<html>
<head>
<script>
function print(val){
	document.getElementById("output").value+=val+"\n";
}
function readline(){
	return prompt("","");
}
</script>
<script src="wzvm.js"></script>
</head>
<body onload="doclr();">
<script>
function doval(){
	if(wz.debug){
		wzprint=print;
		print=function(x){
			x=confirm(x);
			if(!x){
				realmax=wz.MAXINS;
				wz.MAXINS=0;
			}
		}
	}else{
		if(window.wzprint){
			print=wzprint;
		}
	}
	var f=wz.eval(document.getElementById("code").value);
	if(window.realmax)wz.MAXINS=realmax;
	if((f*1)!=(f))alert(f);
	for(var i=0;i<10;i++){
		document.getElementById("w"+i+"x").value=wz.ex[i];
	}
}
function stack(){
	alert(wz.W_memory.slice(0,wz.W_top).join("\n"));
	var mm=prompt("","");
	if(mm!=null && mm!=undefined && mm!=""){
		wz.W_memory[wz.W_top++]=Math.floor(mm)%10000;
		stack();
	}
}
function mr(a,b){
	if(b)wz.ex[b]=Math.floor(a);
}
function doclr(){
	wz=new WZVM();
	wz.debug=false;
	wz.int[3]=function(){alert(wz.W_memory.slice(0,wz.W_top).join("\n"));}
	document.getElementById("output").value="Output:\n";
	for(var i=0;i<10;i++){
		document.getElementById("w"+i+"x").value=wz.ex[i];
	}
}
function bp(){
	var f=Math.floor(prompt("Linea:",""));
	if(f!=null && f!=undefined && f!=""){
		wz.bp[Math.floor(f)]=!wz.bp[Math.floor(f)];
	}
}
</script>
<table style="height:95%; width: 100%"><tr><td style="width:5%">
<textarea style="height: 100%;width: 100%" id=lines readOnly>0
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40</textarea></td><td width="90%"><textarea style="height: 100%;width: 100%" id=code><codigo</textarea></td><td>
<table style="height: 100%; width: 100%">
<tr><td>e0x</td><td><input size=1 id="w0x" readOnly type=text onkeypress="mr(this.value,0)"></td></tr>
<tr><td>e1x</td><td><input size=1 id="w1x" type=text onkeypress="mr(this.value,1)"></td></tr>
<tr><td>e2x</td><td><input size=1 id="w2x" type=text onkeypress="mr(this.value,2)"></td></tr>
<tr><td>e3x</td><td><input size=1 id="w3x" type=text onkeypress="mr(this.value,3)"></td></tr>
<tr><td>e4x</td><td><input size=1 id="w4x" type=text onkeypress="mr(this.value,4)"></td></tr>
<tr><td>e5x</td><td><input size=1 id="w5x" type=text onkeypress="mr(this.value,5)"></td></tr>
<tr><td>e6x</td><td><input size=1 id="w6x" type=text onkeypress="mr(this.value,6)"></td></tr>
<tr><td>e7x</td><td><input size=1 id="w7x" type=text onkeypress="mr(this.value,7)"></td></tr>
<tr><td>e8x</td><td><input size=1 id="w8x" type=text onkeypress="mr(this.value,8)"></td></tr>
<tr><td>e9x</td><td><input size=1 id="w9x" type=text onkeypress="mr(this.value,9)"></td></tr>
</table></td></tr><tr><td colspan=3 height="50px">
<textarea style="height: 100%;width: 100%" id=output>Salida:
</textarea></td></tr></table>
<input type="button" value="Reset" onclick="doclr();">
<input type="button" value="Eval" onclick="doval();">
<input type=button onclick="stack();" value="Stack"> <input onclick="bp();" type=button value='Breakpoints'>
<input type="checkbox" onclick="wz.debug=!wz.debug;this.checked=wz.debug;"> Debug
<a href="wazm.txt">Documentation.</a>
</body>
</html>